<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         // 对数组['关羽', '张飞', '程咬金', '张飞', '吕布'],进行去重，
        // 得到新的数组：['关羽', '张飞', '程咬金', '吕布'];
        // 遍历老数组，判断如果新数组中该元素不存在，则添加
        let arr=['关羽', '张飞', '程咬金', '张飞', '吕布'];
        let arr1=['李白'];
        for(let i = 0;i <arr.length;i++)
        {
            // let str = arr[i];
            let isCommon =false;
            for(let j = 0;j <arr1.length;j++){
                if(arr[i]==arr1[j]){
                    isCommon=true;
                }
            }
            if(!isCommon){
                arr1[arr1.length]=arr[i];
            }
        }
        arr=arr1;
        console.log(arr);

        // 作业：
        // 对数组 arr = [1,2,3,3,5,3,2,4,8,19,10];进行去重;

        let arr2 =[1,2,3,3,5,3,2,4,8,19,10];
        let arr3 =new Array();
        for(let i = 0;i <arr2.length;i++){
            let isCommon=false;
            for(let j = 0;j <arr3.length;j++){
             if(arr2[i]==arr3[j]){
                isCommon=true;
             }
            }
            if(!isCommon){
                 arr3[arr3.length]=arr2[i];
            }
        }
        arr2=arr3;
        console.log(arr2);
    </script>
</body>
</html>